import axios from 'axios'

export const baseURL = import.meta.env.VITE_API_URL

const service = axios.create({
    baseURL,
    timeout: 100000,
})

// 响应拦截器
service.interceptors.response.use(
    (res) => {
        if (res.status === 200) {
            if (res.data?.code === 0) {
                return res.data
            } else {
                return { code: 500 }
            }
        }
    },
    (error) => {
        return Promise.reject(error)
    }
)

export default service
